//创建各种数据库的模型（操作器），并且导出使用
//导入mongoose第三方
const mongoose=require('mongoose')
//创建一个用户相关的模型
const user=new mongoose.Schema({
    username:{type:String,required:true,minlength:3,maxlength:11},
    password:{type:String,required:true,minlength:6,maxlength:18},
    nickname:{type:String,required:true,minlength:3,maxlength:11},
    age:{type:Number,default:0},
    gender:{type:String,enum:['男','女','保密'],default:'男'},
    desc:{type:String,maxlength:40},
    avatar:{type:String,default:'../public/avatar/default.jpg'},
    creatTime:{type:Date,default:new Date()}
})
//创建一个轮播图相关的模型
const banner=new mongoose.Schema({
    title:{type:String,required:true,minlength:3,maxlength:12},
    img_url:{type:String,required:true},
    link:{type:String,default:'http://www.mobiletrain.org/?pinzhuanbdtg=guanwang'},
    creatTime:{type:Date,default:new Date()}
})

//创建一个网站相关用户的模型
const person=new mongoose.Schema({
    username:{type:String,required:true,minlength:3,maxlength:11},
    password:{type:String,required:true,minlength:6,maxlength:18},
    nickname:{type:String,required:true,minlength:3,maxlength:11},
    age:{type:Number,default:0},
    gender:{type:String,enum:['男','女','保密'],default:'男'},
    desc:{type:String,maxlength:40},
    is_status:{type:Boolean,default:true},
    avatar:{type:String,default:'/public/avatar/default.jpg'},
    creatTime:{type:Date,default:new Date()}
})
//导出相关模型
module.exports={
    //导出用户相关操作器
    UserModel:mongoose.model('users',user),
    BannerModel:mongoose.model('banners',banner),
    PersonModel:mongoose.model('persons',person)
}